package com.mall.b2c.domain.member;

import java.math.BigDecimal;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mall.b2c.enums.DetailType;
import com.mall.b2c.util.DictionaryUtils;
import com.mall.common.domain.BaseEntity;


/**
 * 收支明细
 */
@Entity
@Table(name = "b2c_payment_detail")
public class PaymentDetailDomain extends BaseEntity {

	private static final long serialVersionUID = -4777969117656646647L;
	private String paymentNo;// 流水号
	private DetailType detailType;// 类型
	private BigDecimal amount;// 收支金额
	private BigDecimal balance;// 余额
	private String remarks;// 备注
	private String operator;//操作员
	@JsonIgnore private MemberDomain member;//客户
	private String dealId;//第三方支付平台支付编号
	private String paymentTypeName;//支付方式名称
	private String tradeNo;//交易编号
	
	/**
	 * 获取交易详情
	 * @return
	 */
	@Transient
	public String getDetailInfo(){

		String detail = DictionaryUtils.getEnumName(detailType);
		if(StringUtils.isNotBlank(remarks)){
			detail = detail + "-" + remarks;
		}
		return detail;
	}

	public String getPaymentNo() {
		return paymentNo;
	}

	public void setPaymentNo(String paymentNo) {
		this.paymentNo = paymentNo;
	}

	public DetailType getDetailType() {
		return detailType;
	}

	public void setDetailType(DetailType detailType) {
		this.detailType = detailType;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public BigDecimal getBalance() {
		return balance;
	}

	public void setBalance(BigDecimal balance) {
		this.balance = balance;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	public MemberDomain getMember() {
		return member;
	}

	public void setMember(MemberDomain member) {
		this.member = member;
	}

	public String getOperator() {
		return operator;
	}
	
	public void setOperator(String operator) {
		this.operator = operator;
	}

	public String getDealId() {
		return dealId;
	}

	public void setDealId(String dealId) {
		this.dealId = dealId;
	}

	public String getPaymentTypeName() {
		return paymentTypeName;
	}

	public void setPaymentTypeName(String paymentTypeName) {
		this.paymentTypeName = paymentTypeName;
	}

	public String getTradeNo() {
		return tradeNo;
	}

	public void setTradeNo(String tradeNo) {
		this.tradeNo = tradeNo;
	}
	
}
